package frame.networks.tables;

import java.util.List;

import javax.swing.table.DefaultTableModel;

import model.components.networks.network.VirtualNetwork;

@SuppressWarnings("serial")
public class VirtualNetworksTableModel extends DefaultTableModel
{
	private List< VirtualNetwork > virtualNetworks;
	public List< VirtualNetwork > getVirtualNetworks(){ return virtualNetworks; }
	public void setVirtualNetworks( List< VirtualNetwork > virtualNetworks ){ this.virtualNetworks = virtualNetworks; } 
	
	public VirtualNetworksTableModel( String[] columnNames, int rowCount, List< VirtualNetwork > virtualNetworks )
	{
		super( columnNames, rowCount );
		
		this.setVirtualNetworks( virtualNetworks );
	}

	@Override
	public boolean isCellEditable( int x, int y )
	{
		return false;
	}

	public void refresh()
	{
		this.setRowCount( 0 );
		
		for( VirtualNetwork virtualNetwork: this.getVirtualNetworks() )
			this.addRow( new Object[]{ virtualNetwork.getName(), virtualNetwork.getStartingDate(), virtualNetwork.getEndingDate(), virtualNetwork.getState() } );
	}

}
